//
//  AppUtil.m
//  AXT_Personal
//
//  Created by luocena on 15/2/6.
//  Copyright (c) 2015年 淮安微赢. All rights reserved.
//

#import "AppUtil.h"
#import "MBProgressHUD.h"

//FrameWork
#import <QuartzCore/CADisplayLink.h>

@interface AppUtil ()

@end

@implementation AppUtil

+ (void) showTipMessage:(NSString *)msg BackUIView:(UIView *)view
{    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    
    // Configure for text only and offset down
    hud.mode = MBProgressHUDModeText;
    hud.labelText = msg;
    hud.margin = 10.f;
    //	hud.yOffset = 150.f;
    hud.removeFromSuperViewOnHide = YES;
    [hud hide:YES afterDelay:2];
}

+ (void) showTipMessage:(NSString *)msg
{
    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
    
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    backView.backgroundColor = [UIColor blackColor];
    backView.tag = 4001;
    backView.alpha = 0.8f;
    [window addSubview:backView];
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
    
    // Configure for text only and offset down
    hud.mode = MBProgressHUDModeText;
    hud.labelText = msg;
    hud.margin = 10.f;
    //	hud.yOffset = 150.f;
    hud.removeFromSuperViewOnHide = YES;
    [hud hide:YES afterDelay:1];
    
    [UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        backView.alpha = 0.1f;
    } completion:^(BOOL finished) {
        if (finished) {
            if (backView.hidden == NO) {
                backView.hidden = YES;
                [[window viewWithTag:4001] removeFromSuperview];
            }
        }
    }];
}

@end
